/*
 * Copyright (c) 2012 Sean Connelly
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

var assert = require('../assert.js').init();
var byteList = require('../../src/js/byte-list.js');

exports.run = function(root_dir, test_dir, test_name) {

		var b = byteList.create();

		b.clear().pushByte(0x10, 0x21, 0x32);
		assert.that('pushByte', b.toString() == 'byteList{10 21 32}');

		b.clear().pushSbyte(-1, -2, -3);
		assert.that('pushSbyte', b.toString() == 'byteList{ff fe fd}');

		b.clear().pushUshortLE(0x1234, 0x5678);
		assert.that('pushUshortLE', b.toString() == 'byteList{34 12 78 56}');

		b.clear().pushUshortBE(0x1234, 0x5678);
		assert.that('pushUshortBE', b.toString() == 'byteList{12 34 56 78}');

		b.clear().pushShortLE(-1, -2);
		assert.that('pushShortLE', b.toString() == 'byteList{ff ff fe ff}');

		b.clear().pushShortBE(-1, -2);
		assert.that('pushShortBE', b.toString() == 'byteList{ff ff ff fe}');

		b.clear().pushUintLE(0x12345678, 0x9abcdef0);
		assert.that('pushUintLE', b.toString() == 'byteList{78 56 34 12 f0 de bc 9a}');

		b.clear().pushUintBE(0x12345678, 0x9abcdef0);
		assert.that('pushUintBE', b.toString() == 'byteList{12 34 56 78 9a bc de f0}');

		b.clear().pushIntLE(-1, -2);
		assert.that('pushIntLE', b.toString() == 'byteList{ff ff ff ff fe ff ff ff}');

		b.clear().pushIntBE(-1, -2);
		assert.that('pushIntBE', b.toString() == 'byteList{ff ff ff ff ff ff ff fe}');

		b.clear().pushSingleLE(1.5);
		assert.that('pushSingleLE', b.toString() == 'byteList{00 00 c0 3f}');

		b.clear().pushSingleBE(1.5);
		assert.that('pushSingleBE', b.toString() == 'byteList{3f c0 00 00}');

		b.clear().pushDoubleLE(1.5);
		assert.that('pushDoubleLE', b.toString() == 'byteList{00 00 00 00 00 00 f8 3f}');

		b.clear().pushDoubleBE(1.5);
		assert.that('pushDoubleBE', b.toString() == 'byteList{3f f8 00 00 00 00 00 00}');

		return assert.result();
	};
